home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Tools 3
/
Amiga Tools 3.iso
/
grafik
/
raytracing
/
rayshade-4.0.6.3
/
inetray
/
socketpair.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-08-15
|
1KB
|
42 lines
/*======================================================================
S O C K E T P A I R . C
doc: Tue Mar 31 15:12:52 1992
dlm: Tue Mar 31 16:24:54 1992
(c) 1992 ant@ips.id.ethz.ch
uE-Info: 40 73 T 0 0 72 2 2 ofnI
======================================================================*/
/*
socketpair() implementation for A/UX (guack!)
*/
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/un.h>
int socketpair(d,type,protocol,sv)
int d,type,protocol,sv[2];
{
int lSock,aLen;
struct sockaddr_un name;
lSock = socket(d,type,protocol); /* listen s when tcp */
if (lSock < 0) return -1;
name.sun_family = d; /* bind address */
tmpnam(name.sun_path); /* in /tmp */
if (bind(lSock,&name,sizeof(name)) < 0)
return -1;
if ((type != SOCK_DGRAM) && (listen(lSock,1) < 0))
return -1;
sv[1] = socket(d,type,protocol); /* get other side */
if (sv[1] < 0) return -1;
if (connect(sv[1],&name,sizeof(name)) < 0) /* connect it */
return -1;
aLen = sizeof(name);
if (type == SOCK_DGRAM) sv[0] = lSock; /* get socket */
else sv[0] = accept(lSock,&name,&aLen);
if (sv[0] < 0) return -1;
return 0; /* all correct */
}